package com.crawler.crawler.controller;

import com.crawler.crawler.service.ZyuCrawlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ZyuController {

    @Autowired
    private ZyuCrawlerService zyuCrawlerService;
//    @Override
//    public void process(Page page) {
////        page.putField("author",page.getHtml().xpath("/html/body/div/div/div[3]/div/div/section").all());
//        //查找链接的最后一页面
//        String lastPage=page.getHtml().css("a.extend").links().toString();
//        String[] lastPages=lastPage.split("/page/");
//        int aa=Integer.parseInt(lastPages[1].replaceAll("/",""));
//        //查找div 下class为kratos-entry-thumb-new 的所有元素，用来查询链接使用
//        List<String> list=page.getHtml().css("div.kratos-entry-thumb-new").links().regex("(http://www.zzyyu.com/index.php/(\\d){4}/(\\d){2}/(\\d){2}/(.*))").all();
////        for (int i=0; i<list.size();i++){
////            System.out.println(list.get(i));
////        }
//    }


    @GetMapping("/getZyu")
    @ResponseBody
    public String getZyu(){
//        int aa=zyuCrawlerService.getPages();
//        zyuCrawlerService.getBookList(1);
        zyuCrawlerService.spider();
        return  "111";
    }



}
